<template>
	<view class="event-container">
		<uni-nav-bar left-icon="back" title="实时告警" color="#fff" backgroundColor="#26dfd4" fixed
			@clickLeft="leftIconClick">
		</uni-nav-bar>
		<view class="content" :style="{marginTop:height +20 +'px'}">
			<view class="event-list" v-for="item in alarmList" :key="item.alarmId">
				<view class="event-list-title">
					<image src="../../static/event.png" mode=""></image>
					<text>{{item.engName}}【{{item.beginStakeNo}}】</text>
				</view>
				<view class="event-list-content">
					<view class="desc"><text>{{item.updateTime}}</text> <text>【{{item.deviceName}}】</text>
						<text>{{item.alarmInfo}}</text></view>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	import {
		myRequest
	} from '../../utils/request.js'
	export default {
		data() {
			return {
				list: [],
				queryVo: {
					"disposalStatus": 1,
					"isToday": true,
					"wayId": ""
				},
				alarmList: [], // 告警列表
				height: null
			}
		},
		onLoad() {
			const info = uni.getStorageSync('info')
			this.queryVo.wayId = info.id
			let _this = this
			uni.getSystemInfo({
				success: function(data) {
					// 将其赋值给this
					_this.height = data.statusBarHeight;
				}
			})
			this.getAlarmList()
		},
		methods: {
			// 获取告警列表
			async getAlarmList() {
				const {
					data: {
						code,
						data,
						msg
					}
				} = await myRequest({
					//#ifdef  H5
					url: `/btp/system/eng-alarm/unOptList`,
					//#endif
					//#ifdef  MP-WEIXIN
					url: `http://139.224.204.68:10001/btp/system/eng-alarm/unOptList`,
					//#endif
					method: 'POST',
					data: this.queryVo
				})
				if (code == '200') {
					this.alarmList = data
				} else {
					uni.showToast({
						title: "请求接口失败！"
					})
				}
			},
			leftIconClick() {
				uni.navigateTo({
					url: '/pages/index/index'
				});
			},
			// 定义一个事件等级的函数
			getEventLevelType(val) {
				switch (parseInt(val)) {
					case 1:
						return {
							name: "Ⅰ级",
								color: '#7f131f',
						}
						case 2:
							return {
								name: "Ⅱ级",
									color: '#7c4f14',
							}
							case 3:
								return {
									color: '#11e5e8',
										name: "Ⅲ级"
								}
								case 4:
									return {
										color: '#0a5c92',
											name: "Ⅳ级"
									}
									case 5:
										return {
											color: '#0a8491',
												name: "Ⅴ级"
										}
				}
			},
		}
	}
</script>

<style lang="less" scoped>
	@import './../../utils/mixin.less';

	view {
		box-sizing: border-box;
	}

	.event-container {
		/* border: 1px solid #d4d4d4; */
		padding: 20rpx;
		padding-top: 0;

		.event-list {
			position: relative;
			width: 100%;
			.box-shadow();
			border-radius: 6rpx;
			padding: 20rpx;
			margin-bottom: 20rpx;

			.time {
				position: absolute;
				top: 0rpx;
				right: 0rpx;
				font-size: 24rpx;
				color: #ccc;
			}

			.event-list-title {
				padding: 20rpx 0;
				// .box-shadow();
				border-bottom: 1px solid #d4d4d4;
				display: flex;
				align-items: center;

				image {
					width: 30rpx;
					height: 30rpx;
					border: 1px solid #d4d4d4;
					border-radius: 50%;
				}

				text {
					color: #000;
					font-weight: 700;
					font-size: 28rpx;
					margin-left: 4rpx;
				}
			}
		}

		.event-list-content {
			font-size: 24rpx;

			.desc {
				line-height: 60rpx;

				text {
					&:nth-child(2) {
						color: #000;
						margin: 0 10rpx;
					}
				}
			}

		}
	}
</style>
